package com.imagesystem.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.imagesystem.common.annotation.Log;
import com.imagesystem.common.enums.BusinessType;
import com.imagesystem.system.domain.WashRecordInfo;
import com.imagesystem.system.service.IWashRecordInfoService;
import com.imagesystem.common.core.controller.BaseController;
import com.imagesystem.common.core.domain.AjaxResult;
import com.imagesystem.common.utils.poi.ExcelUtil;
import com.imagesystem.common.core.page.TableDataInfo;

/**
 * 内镜洗消记录明细Controller
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Controller
@RequestMapping("/system/recordInfo")
public class WashRecordInfoController extends BaseController
{
    private String prefix = "system/recordInfo";

    @Autowired
    private IWashRecordInfoService washRecordInfoService;

    @RequiresPermissions("system:recordInfo:view")
    @GetMapping()
    public String info()
    {
        return prefix + "/recordInfo";
    }

    /**
     * 查询内镜洗消记录明细列表
     */
    @RequiresPermissions("system:recordInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WashRecordInfo washRecordInfo)
    {
        startPage();
        List<WashRecordInfo> list = washRecordInfoService.selectWashRecordInfoList(washRecordInfo);
        return getDataTable(list);
    }

    /**
     * 导出内镜洗消记录明细列表
     */
    @RequiresPermissions("system:recordInfo:export")
    @Log(title = "内镜洗消记录明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WashRecordInfo washRecordInfo)
    {
        List<WashRecordInfo> list = washRecordInfoService.selectWashRecordInfoList(washRecordInfo);
        ExcelUtil<WashRecordInfo> util = new ExcelUtil<WashRecordInfo>(WashRecordInfo.class);
        return util.exportExcel(list, "内镜洗消记录明细数据");
    }

    /**
     * 新增内镜洗消记录明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存内镜洗消记录明细
     */
    @RequiresPermissions("system:recordInfo:add")
    @Log(title = "内镜洗消记录明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WashRecordInfo washRecordInfo)
    {
        return toAjax(washRecordInfoService.insertWashRecordInfo(washRecordInfo));
    }

    /**
     * 修改内镜洗消记录明细
     */
    @RequiresPermissions("system:recordInfo:edit")
    @GetMapping("/edit/{washBatch}")
    public String edit(@PathVariable("washBatch") String washBatch, ModelMap mmap)
    {
        WashRecordInfo washRecordInfo = washRecordInfoService.selectWashRecordInfoByWashBatch(washBatch);
        mmap.put("washRecordInfo", washRecordInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存内镜洗消记录明细
     */
    @RequiresPermissions("system:recordInfo:edit")
    @Log(title = "内镜洗消记录明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WashRecordInfo washRecordInfo)
    {
        return toAjax(washRecordInfoService.updateWashRecordInfo(washRecordInfo));
    }

    /**
     * 删除内镜洗消记录明细
     */
    @RequiresPermissions("system:recordInfo:remove")
    @Log(title = "内镜洗消记录明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(washRecordInfoService.deleteWashRecordInfoByWashBatchs(ids));
    }
}
